import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Login',
        component: () => import('../views/Login'),
        hidden:true
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('../views/Home')
    },

// {
//   path: '/about',
//   name: 'About',
//   // route level code-splitting
//   // this generates a separate chunk (about.[hash].js) for this route
//   // which is lazy-loaded when the route is visited.
//   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
// }
]

const router = new VueRouter({
    routes
})
//2.使用router.beforeEach对路由进行遍历，设置title
router.beforeEach((to, from, next) => {
    //beforeEach是router的钩子函数，在进入路由前执行
    if (to.meta.title) {
        //判断是否有标题
        console.log(to.meta.title)
        document.title = to.meta.title
    } else {
        document.title = 'yeb管理平台'
    }
    next()
})

export default router
